<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../../config.inc.php");

$_LangPath = "usercredit";
include(__Admin_Path."/logincheck.php");
include(__Language_Path."/selectlanguage_admin.php");
include(__Modules_Path."/Member.lib.php");
include(__Modules_Path."/BetLimit.lib.php");
include(__Modules_Path."/Commission.lib.php");
include(__Common_Path."/Lotto.inc.php");

$fp = @file(__Admintemplate_Path."/UserCredit/CreditData.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

$fp = str_replace("{Show_Account}", $_SESSION["Admin_Info"] -> Account, $fp);
$fp = str_replace("{Show_Name}", $_SESSION["Admin_Info"] -> Name, $fp);

while(list($k, $v) = each($_strUserCredit)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

preg_match("/<!--@ Lotto While Start @\/\/-->(.+)<!--@ Lotto While End @\/\/-->/s", $fp, $arrLotto);
preg_match("/<!--@ Limits While Start @\/\/-->(.+)<!--@ Limits While End @\/\/-->/s", $fp, $arrLimit);
$strLottoTmp = $arrLotto[1];
$strLimitTmp = $arrLimit[1];
$arrGT = array(1 => "A", 2 => "B", 3 => "C");

$arrComm = getUserCommissionArray($_SESSION["Admin_Info"] -> ID);
if($arrComm === false){
	ErrMsgOutputHTML("Error", "", 1);
}

$strCon = "";
foreach($_arrLotto as $intLID => $arrLo){
	$arrBT = getBetTypeNameArray($arrLo["LType"]);
	$arrLimits = getUserLimitsArray($_SESSION["Admin_Info"] -> ID, $intLID);
	if($arrLimits === false){
		ErrMsgOutputHTML("Error", "", 1);
	}

	$strLimit = "";
	$strLotto = "";
	foreach($arrBT as $intBT => $strBT){
		$c2 = str_replace("{Show_BetType}", $strBT, $strLimitTmp);
		$c2 = str_replace("{Show_ELimit}", $arrLimits[0][$intBT], $c2);
		foreach($arrGT as $intGT => $strGT){
			$c2 = str_replace("{Show_GLine".$intGT."}", $arrComm[$intLID][$intBT][$intGT], $c2);
		}
		$strLimit .= str_replace("{Show_BLimit}", $arrLimits[1][$intBT], $c2);
	}
	$strLotto = preg_replace("/<!--@ Limits While Start @\/\/-->.+<!--@ Limits While End @\/\/-->/s", $strLimit, $strLottoTmp);
	$strCon .= str_replace("{LottoName}", $arrLo["Lotto_".$_intLang], $strLotto);
}
$fp = preg_replace("/<!--@ Lotto While Start @\/\/-->.+<!--@ Lotto While End @\/\/-->/s", $strCon, $fp);

//找出信用額度
$arrUser = getUserDataArrayByID($_SESSION["Admin_Info"] -> ID);
if($arrUser === false){
	ErrMsgOutputHTML("Error", "", 1);
}
$fp = str_replace("{Show_CreditLine}", $arrUser["CreditLine"], $fp);

//找出已使用信用額度
$intUsedCredit = getChildSumCreditLine($_SESSION["Admin_Info"] -> ID, "", 0);
if($intUsedCredit === false){
	ErrMsgOutputHTML("Error", "", 1);
}
$fp = str_replace("{UsedCredit}", $intUsedCredit, $fp);

//輸出
WebOutputHTML($fp, 1);
?>